package CommonAlgs.recursion;

public class PascalTriangle {
    public static void main(String[] args) {
        int res = f(5, 4);
        System.out.println(res);
    }

    private static int f(int x, int y) {
        int n = Math.max(x, y);
        int[][] triangle = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || i == j) {
                    triangle[i][j] = 1;
                } else {
                    triangle[i][j] = triangle[i - 1][j] + triangle[i - 1][j - 1];
                }
            }
        }
        return triangle[x - 1][y - 1];
    }
}
